import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

export default defineConfig({
  outputDir: "dist/esign",
  transpileDependencies: true,
  server: {
    host: "0.0.0.0",
    port: 8081,
    open: false, // vue项目启动时自动打开浏览器
    proxy: {
      "/openSign": {
        target: "http://127.0.0.1:6688",
        changeOrigin: true,
      },
      "/kaifangqian": {
        target: "https://xeyx.hbszfcgxh.com:10443",
        // 本地调用线上
        // target: "https://kfq.hbszfcgxh.com:10443/",
        changeOrigin: true,
      },
      "/ent": {
        target: "http://127.0.0.1:6688",
        changeOrigin: true,
      },
    },
  },
  plugins: [vue()],
  // optimizeDeps: {
  //   include: ["pdfjs-dist/build/pdf.worker.min"],
  // },
  base: "./",
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  build: {
    target: "es2020",
    cssTarget: "chrome80",
    outDir: "dist/esign",
    // rollupOptions: {
    //   output: {
    //     manualChunks: {
    //       pdfjsWorker: ["pdfjs-dist/build/pdf.worker.min"],
    //     },
    //   },
    // },
  },
});
